﻿@model Piedone.ContentTemplates.Models.TemplatePart

@{
    Style.Include("admin.piedone-content-templates.css");
    Script.Require("jQuery").AtFoot();
}

<fieldset class="piedone-content-templates-save-as-template">
    @Html.HiddenFor(m => m.IsTemplate)
    <button class="piedone-content-templates-save-button">@T("Save as template")</button>
</fieldset>

@using (Script.Foot()) {
    <script type="text/javascript">
        (function ($) {
            $(".piedone-content-templates-save-button").click(function () {
                var $isTemplate = $("#@Html.FieldIdFor(m => m.IsTemplate)");
                $isTemplate.val("true");
                var $saveButton = $("button[name='submit.Save']");
                if ($saveButton.length > 0) $saveButton.click();
                else $($isTemplate[0].form).submit();
            });
        })(jQuery);
    </script>
}